/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.lzyzsd.circleprogress.demo.slice;

import com.github.lzyzsd.circleprogress.demo.ListAbility;
import com.github.lzyzsd.circleprogress.demo.ResourceTable;
import com.github.lzyzsd.circleprogress.demo.SlideAbility;
import com.github.lzyzsd.circleprogress.demo.StaticAbility;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Text;

public class MenuSlice extends AbilitySlice {
    private static final String TAG = MenuSlice.class.getSimpleName();
    private Text button;
    private Text button2;
    private Text button3;
    private Text button4;

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_menu_layout);
        button = (Text) findComponentById(ResourceTable.Id_bt_main_slice);
        button2 = (Text) findComponentById(ResourceTable.Id_bt_main_slice2);
        button3 = (Text) findComponentById(ResourceTable.Id_bt_main_list);
        button4 = (Text) findComponentById(ResourceTable.Id_bt_main_static);
        button.setClickedListener(component -> {
            present(new MainAbilitySlice(), new Intent());
        });
        button2.setClickedListener(component -> {
            Intent.OperationBuilder builder = new Intent.OperationBuilder();
            builder.withAbilityName(SlideAbility.class);
            builder.withAction("action.main.slide");
            builder.withBundleName(getBundleName());
            Intent i= new Intent();
            i.setOperation(builder.build());
            startAbility(i);
        });
        button3.setClickedListener(component -> {
            Intent.OperationBuilder builder = new Intent.OperationBuilder();
            builder.withAbilityName(ListAbility.class);
            builder.withAction("action.main.list");
            builder.withBundleName(getBundleName());
            Intent i= new Intent();
            i.setOperation(builder.build());
            startAbility(i);
        });
        button4.setClickedListener(component -> {
            Intent.OperationBuilder builder = new Intent.OperationBuilder();
            builder.withAbilityName(StaticAbility.class);
            builder.withBundleName(getBundleName());
            Intent i = new Intent();
            i.setOperation(builder.build());
            startAbility(i);
        });
    }
}
